package com.dynamic.idea.quick.develop.plugin.utils;

import cn.hutool.core.util.IdUtil;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationDisplayType;
import com.intellij.notification.NotificationGroup;
import com.intellij.notification.Notifications;
import com.intellij.openapi.ui.MessageType;
import org.apache.commons.lang3.StringUtils;

/**
 * 通知相关
 */
public class NotifyUtils {

    /**
     * 发送通知
     * @param message
     */
    public static void notifyInfo(String message){
        notify(message,"notifyInfo",MessageType.INFO);
    }
    /**
     * 发送警告
     * @param message
     */
    public static void notifyWarning(String message){
        notify(message,"notifyWaring",MessageType.WARNING);
    }

    private static void notify(String message,String displayId,MessageType messageType){
        displayId=displayId+"_"+ IdUtil.simpleUUID();
        NotificationGroup group = new NotificationGroup(displayId, NotificationDisplayType.BALLOON, true);
        Notification notification = group.createNotification(StringUtils.trimToEmpty(message), messageType);
        Notifications.Bus.notify(notification);
    }
}
